local a = wbuffer_create()
wbuffer_write_uint8(a,16)
assert((wbuffer_get_cursor(a) == 1))
wbuffer_write_uint16(a,4386)
assert((wbuffer_get_cursor(a) == 3))
wbuffer_write_uint32(a,287454020)
assert((wbuffer_get_cursor(a) == 7))
wbuffer_write_uint64(a,1234605616436508552)
assert((wbuffer_get_cursor(a) == 15))
wbuffer_write_string(a,"hello")
assert((wbuffer_get_cursor(a) == 21))
wbuffer_write_binary(a,"wolrd",6)
assert((wbuffer_get_cursor(a) == 27))
local b = rbuffer_create(wbuffer_get_data(a),wbuffer_get_cursor(a))
assert((rbuffer_get_cursor(b) == 0))
assert((rbuffer_read_uint8(b) == 16))
assert((rbuffer_get_cursor(b) == 1))
assert((rbuffer_read_uint16(b) == 4386))
assert((rbuffer_get_cursor(b) == 3))
assert((rbuffer_read_uint32(b) == 287454020))
assert((rbuffer_get_cursor(b) == 7))
print(rbuffer_read_uint64(b))
assert((rbuffer_get_cursor(b) == 15))
assert((rbuffer_read_string(b) == "hello"))
assert((rbuffer_get_cursor(b) == 21))
local c = rbuffer_read_binary(b,6)
assert((rbuffer_get_cursor(b) == 27))
wbuffer_rewind(a)
assert((wbuffer_get_cursor(a) == 0))
wbuffer_write_binary(a,c)
assert((wbuffer_get_cursor(a) == 6))
